export default ({ http }) => ({
  /**
   * 请求接口命名规则
   * @param { post }   create  创建
   * @param { delete } delete  删除
   * @param { put }    update  更新
   * @param { get }    get     查看
   */

  // 资讯 - 首页
  getTopicIndex(query, response, error) {
    return http.get('/topic/index', query, response, error)
  },

  // 资讯 - 列表
  getTopicList(query, response, error) {
    return http.get('/topic/list', query, response, error)
  },

  // 资讯 - 详情
  getTopicDetails(id, query, response, error) {
    return http.get(`/topic/${id}/fetch`, query, response, error)
  },

  // 资讯 - 添加评论
  createTopicComment(id, query, response, error) {
    return http.post(`/topic/${id}/comment`, query, response, error)
  },

  // 资讯 - 评论点赞
  updateTopicCommentLike(id, query, response, error) {
    return http.put(`/topic/comment/${id}/like`, query, response, error, false)
  },

  // 资讯 - 回复列表
  getTopicCommentReply(id, query, response, error) {
    return http.get(`/topic/comment/${id}/reply`, query, response, error, false)
  },
  // 资讯 - 回复评论
  createTopicCommentReply(id, query, response, error) {
    return http.post(`/topic/comment/${id}/reply`, query, response, error, false)
  },
  // 删除评论
  deleteTopicComment(id, response, error) {
    return http.delete(`/topic/comment/${id}`, {}, response, error, false)
  },
  // 删除评论回复
  deleteTopicCommentReply(id, response, error) {
    return http.delete(`/topic/reply/${id}`, {}, response, error, false)
  }
})
